package com.jy.adscm.operation.pebase.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.pebase.bean.PePicture;
import com.jy.adscm.operation.pebase.mapper.mysql.PePictureMapper;
import com.jy.adscm.operation.pebase.service.PePictureService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-08-19
 */
@Service
public class PePictureServiceImpl extends ServiceImpl<PePictureMapper, PePicture> implements PePictureService {
     @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<PePicture> selectByDid(Integer id) {
        Wrapper<PePicture> wrapper=new EntityWrapper<>();
        wrapper.eq("did",id);
        List<PePicture> pePictures = super.selectList(wrapper);
        for (PePicture pePicture : pePictures) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(pePicture.getUploader(),null)){
                JyUser jyUser = jyUserMapper.selectById(pePicture.getUploader());
                pePicture.setUploaderName(jyUser.getName());
            }
        }
        return pePictures;
    }
}
